package com.tanhua.server.contoller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tan.model.domain.Settings;
import com.tan.model.vo.PageResult;
import com.tan.model.vo.SettingsVo;
import com.tanhua.server.service.SettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/users")
public class SettingController {
    @Autowired
    private SettingService settingService;
    /*
    * 查询通用设置
    * */
    @GetMapping("/settings")
    public ResponseEntity getSettings(){
        SettingsVo settingsVo = settingService.getSettings();
        return ResponseEntity.ok(settingsVo);
    }
    @PostMapping("/questions")
    public ResponseEntity updateQuestion(@RequestBody Map map){
      String content = (String)  map.get("content");
      settingService.updateQuestion(content);
      return ResponseEntity.ok(null);

    }
    @PostMapping("/notifications/setting")
    public ResponseEntity updateSettings(@RequestBody Map map){

          settingService.setSettings(map);

                return ResponseEntity.ok(null);
    }
     @GetMapping("/blacklist")
    public ResponseEntity getBlackList(@RequestParam(defaultValue = "1") int page,@RequestParam(defaultValue = "10")int pagesize){
    PageResult pageResult= settingService.getBlackList(page,pagesize);


        return ResponseEntity.ok(pageResult);
     }
     @DeleteMapping("/blacklist/{userId}")
    public ResponseEntity deleteBlackList(@PathVariable Long userId){
        settingService.deleteBlackList(userId);
        return ResponseEntity.ok(null);
     }

}
